#ifndef _BSP_GPIO_H
#define _BSP_GPIO_H

#include "main.h"

/* GPIO端口定义 */
#define TOUCH_CTRL_PORT		    GPIOA
#define TOUCH_CTRL_PIN		    GPIO_PIN_0  // 触摸开关

#define BEEP_CTRL_PORT		    GPIOA
#define BEEP_CTRL_PIN		    GPIO_PIN_1  // 蜂鸣器控制

#define LCDK_CTRL_PORT		    GPIOA
#define LCDK_CTRL_PIN		    GPIO_PIN_3  // 背光负极供电脚 拉高 屏幕导通

#define VBAT_ADC_PORT	        GPIOB
#define VBAT_ADC_PIN	        GPIO_PIN_1  // ADC采总压

#define RS485_CTRL_PORT	        GPIOB
#define RS485_CTRL_PIN	        GPIO_PIN_12  // 485通信使能

#define RS485_TX_PORT	        GPIOA
#define RS485_TX_PIN	        GPIO_PIN_9  // 485 TX
#define RS485_RX_PORT	        GPIOA
#define RS485_RX_PIN	        GPIO_PIN_10 // 485 RX
#define RS485_MODE_PORT         GPIOB
#define RS485_MODE_PIN	        GPIO_PIN_14 // 485 RD_EN 收发模式控制

#define LCDK_CTRL_EN            gpio_bit_set(LCDK_CTRL_PORT, LCDK_CTRL_PIN);
#define LCDK_CTRL_DIS           gpio_bit_reset(LCDK_CTRL_PORT, LCDK_CTRL_PIN);

#define BEEP_CTRL_EN            gpio_bit_set(BEEP_CTRL_PORT, BEEP_CTRL_PIN);
#define BEEP_CTRL_DIS           gpio_bit_reset(BEEP_CTRL_PORT, BEEP_CTRL_PIN);
#define BEEP_TOGGLE	            gpio_bit_write(BEEP_CTRL_PORT, BEEP_CTRL_PIN, (bit_status)!gpio_output_bit_get(BEEP_CTRL_PORT, BEEP_CTRL_PIN));

#define RS485_CTRL_EN           gpio_bit_set(RS485_CTRL_PORT, RS485_CTRL_PIN);
#define RS485_CTRL_DIS          gpio_bit_reset(RS485_CTRL_PORT, RS485_CTRL_PIN);

void bsp_gpio_init(void);

#endif
